package com.lavida.project.system.structure.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lavida.common.utils.security.ShiroUtils;
import com.lavida.framework.web.controller.BaseController;
import com.lavida.framework.web.page.TableDataInfo;
import com.lavida.project.system.structure.domain.Structure;
import com.lavida.project.system.structure.service.StructureService;
@Controller
@RequestMapping("/system/structure")
public class StructureController extends BaseController{
	private String prefix = "system/structure";
	@Autowired
	private StructureService structureService;
	@RequestMapping()
	public String structure(ModelMap mmap) {
		mmap.put("user", ShiroUtils.getSysUser());
		return prefix + "/structure";
	}
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(Structure structure) {
		startPage();				
		List<Structure> selectStructure = structureService.selectStructure(structure);
		return getDataTable(selectStructure);
	}
	@RequestMapping("/showAdd")
	public String showAdd(Structure structure) {
		structureService.insertStructure(structure);
		return "redirect:/system/structure";
	}
		
}
